home *** CD-ROM | disk | FTP | other *** search
/ PCMania 75 / PCMania CD75_1.iso / lycos / netscape / netcast.z / ncjs10.jar / webbar.js < prev    next >
Text File  |  1997-11-26  |  9KB  |  378 lines

  1. /*
  2.  * webbar.js
  3.  * 
  4.  * Copyright (c) 1997 Netscape Communications Corporation, All Rights Reserved
  5.  * 
  6.  * Webtop manager
  7.  */
  8. /*  ValidateWebtop should be called before any function
  9.     in this library.  If there is no current webtop
  10.     (i.e., the webtopWindow is non-null and not marked
  11.     as closed), it returns the webtop window.  Otherwise,
  12.     it returns null. */
  13.     
  14. function ValidateWebtop()
  15. {
  16.     if (this.webtopWindow && (this.webtopWindow.closed == false)) 
  17.     {
  18.         return this.webtopWindow;
  19.     } 
  20.     else 
  21.     {
  22.         this.webtopWindow = null;
  23.         this.webtopHidden = true;
  24.         this.webtopTopped = false;
  25.         return null;
  26.     }    
  27. }
  28.  
  29. function WebtopFixButtons()
  30. {
  31.     var webtop = this.validateWebtop();
  32.     
  33.     if (this.webtopControls && !this.webtopControls.loading) 
  34.     {
  35.         this.webtopControls.fixButtons(webtop);
  36.     }
  37.  
  38.         if (this.webtopSelectorControls && !this.webtopSelectorControls.loading)
  39.     {
  40.         this.webtopSelectorControls.fixButtons(webtop);
  41.     }    
  42. }
  43.  
  44. function WebtopBack() 
  45. {
  46.     var webtop = this.validateWebtop();
  47.     
  48.     if (webtop && !this.webtopHidden) 
  49.     {
  50.         webtop.back();
  51.         this.fixButtons();
  52.     }
  53. }
  54.  
  55. function WebtopForward()
  56. {
  57.     var webtop = this.validateWebtop();
  58.     
  59.     if (webtop && !this.webtopHidden) 
  60.     {
  61.         webtop.forward();
  62.         this.fixButtons();
  63.     }
  64. }
  65.  
  66. function WebtopUpdate()
  67. {
  68.     // hmmm.  This isnt' really correct, since we want to actually do an update
  69.     var webtop = this.validateWebtop();
  70.     
  71.     if (webtop) 
  72.     {
  73.         webtop.reload();
  74.     }
  75. }
  76.  
  77. function WebtopPrint()
  78. {
  79.     var webtop = this.validateWebtop();
  80.     
  81.     if (webtop) 
  82.     {
  83.         webtop.print();
  84.     }
  85. }
  86.  
  87. function WebtopClose()
  88. {
  89.     var webtop = this.validateWebtop();
  90.     
  91.     if (webtop) 
  92.     {
  93.         clearTimeout(this.logoStatusID);
  94.         webtop.close();
  95.         this.webtopWindow = null;
  96.         this.webtopControls.close();
  97.         this.webtopControls = null;
  98.         this.webtopWatermark.close();
  99.         this.webtopWatermark = null;
  100.         this.webtopSite = "";
  101.         this.webtopItem.setWebtopStatus(false);
  102.         this.webtopItem.closing();
  103.         this.webtopItem = null;
  104.         this.fixButtons();
  105.  
  106.         this.webtopHidden = true;
  107.         this.webtopTopped = false;
  108.     }
  109. }
  110.  
  111. function WebtopToggle()
  112. {
  113.     if (this.webtopHidden)
  114.     {
  115.         this.show();
  116.         this.front();
  117.     }
  118.     else
  119.     {
  120.         this.hide();
  121.     }
  122. }
  123.  
  124. function WebtopToggleTop()
  125. {
  126.     if (this.webtopHidden)
  127.         this.show();
  128.  
  129.     if (this.webtopTopped)
  130.         this.behind();
  131.     else
  132.         this.front();
  133. }
  134.  
  135.  
  136. function WebtopHide()
  137. {
  138.     var        webtop = this.validateWebtop();
  139.     
  140.     if (webtop && !this.webtopHidden)
  141.     {
  142.         depth.SecureMoveWindow(webtop, -30000, -30000);
  143. //        depth.SecureMoveWindow(this.webtopControls, -30000, -30000);
  144. //        depth.SecureMoveWindow(this.webtopWatermark, -30000, -30000);
  145.         this.webtopHidden = true;
  146.         this.fixButtons();
  147.     }
  148. }
  149.  
  150. function WebtopShow()
  151. {
  152.     var        webtop = this.validateWebtop();
  153.     var        webtopAnchor = depth.GetNetscapePref("netcaster.webtopDock", "left", false)
  154.     
  155.     if (webtop && this.webtopHidden) 
  156.     {
  157.         if (webtopAnchor == "right") 
  158.             depth.SecureMoveWindow(webtop, screen.availWidth - webtop.outerWidth,screen.availTop);
  159.         else
  160.             depth.SecureMoveWindow(webtop, screen.availLeft,screen.availTop);
  161.  
  162. //        SecureMoveWindow(this.webtopControls, screen.availWidth - 199, screen.availHeight - 25);
  163. //        SecureMoveWindow(this.webtopWatermark, screen.availWidth - 50, screen.availHeight - 75);
  164.  
  165.         this.webtopHidden = false;
  166.         this.fixButtons();
  167.     }
  168.     else
  169.     {
  170. //        this.setWebtop('http://netcaster.netscape.com/channel/index.html');
  171.         this.setWebtop('http://netcaster.netscape.com/channel/beta13.html');
  172.     }
  173.  
  174. }
  175.  
  176. function WebtopFront()
  177. {
  178.     var        webtop = this.validateWebtop();
  179.  
  180.     if (webtop)
  181.     {
  182.         netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); 
  183.  
  184.         webtop.setZOptions("");
  185.         webtop.focus();
  186.         webtop.setZOptions("z-lock=1");
  187.  
  188.         this.webtopControls.setZOptions("");
  189.         this.webtopControls.focus();
  190.         this.webtopControls.setZOptions("z-lock=1");
  191.  
  192.         this.webtopWatermark.setZOptions("");
  193.         this.webtopWatermark.focus();
  194.         this.webtopWatermark.setZOptions("z-lock=1");
  195.  
  196.         this.webtopTopped = true;
  197.     }
  198. }
  199.  
  200.  
  201. function WebtopBehind()
  202. {
  203.     var webtop = this.validateWebtop();
  204.  
  205.     if (webtop)
  206.     {
  207.         netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); 
  208.  
  209.         // This deals with a Windows only bug in setZOptions
  210.         if (depth.isWindows()) {
  211.             webtop.setZOptions("");
  212.             webtop.blur();
  213.             webtop.setZOptions("z-lock=1");
  214.             webtop.setZOptions("alwaysLowered=1");
  215.  
  216.             this.webtopControls.setZOptions("");
  217.             this.webtopControls.blur();
  218.             this.webtopControls.setZOptions("z-lock=1");
  219.             this.webtopControls.setZOptions("alwaysLowered=1");
  220.  
  221.             this.webtopWatermark.setZOptions("");
  222.             this.webtopWatermark.blur();
  223.             this.webtopWatermark.setZOptions("z-lock=1");
  224.             this.webtopWatermark.setZOptions("alwaysLowered=1");
  225.         }
  226.         else {
  227.             this.webtopWatermark.setZOptions("alwaysLowered=1");
  228.             this.webtopControls.setZOptions("alwaysLowered=1");
  229.             webtop.setZOptions("alwaysLowered=1");
  230.         }
  231.  
  232.         this.webtopTopped = false;
  233.     }
  234. }
  235.  
  236.  
  237. function OpenNewNavigator()
  238. {
  239.     var winHeight = screen.availHeight - 10;
  240.     newWindow = window.open("about:blank", 
  241.                 '', 
  242.                 'left=10,top=5,outerWidth=625,outerHeight=" + winHeight + ",toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,dependent=no');
  243.  
  244.     newWindow.home();
  245. }
  246.  
  247. function WebtopSet(siteurl)
  248. {
  249.     sitename = "" + siteurl;
  250.  
  251.     if (sitename == this.webtopSite)
  252.         return;
  253.     
  254.     netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); 
  255.  
  256.     this.closeWebtop();
  257.  
  258.     // the Webtop must be opened first so that they lock bottom before the webtop does
  259.  
  260.     var wcLeft = screen.availLeft + screen.availWidth - 199;
  261.     var wcBottom = screen.availTop + screen.availHeight - 25;
  262.  
  263.     this.webtopControls = depth.SecureWindowOpen(self,"webctrl.htm", "NC_webtop_controls",
  264.         "toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,outerWidth=200,outerHeight=25,screenX=" +
  265.         wcLeft + ",screenY=" +
  266.         wcBottom +
  267.         ",alwaysLowered=1,z-lock=1,dependent=1,titlebar=0,hotkeys=0");
  268.  
  269.     var branding = depth.GetNetscapePref("netcaster.branding.image", null, false);
  270.  
  271.     var wcLeft = screen.availLeft + screen.availWidth - (branding==null?50:92);
  272.     var wcBottom = screen.availTop + screen.availHeight - 75;
  273.  
  274.     this.webtopWatermark = depth.SecureWindowOpen(self,"logo.htm", "NC_webtop_watermark",
  275.         "toolbar=0, directories=0, status=0, menubar=0, scrollbars=0,resizable=0,outerWidth="+(branding==null?42:84)+",outerHeight=42,screenX=" +
  276.         wcLeft + ",screenY=" +
  277.         wcBottom +
  278.         ",alwaysLowered=1,z-lock=1,dependent=1,titlebar=0,hotkeys=0");
  279.  
  280.     this.webtopWindow = depth.SecureWindowOpen(self, sitename, "NC_webtop_win",
  281.         "toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,outerWidth=" +
  282.         screen.availWidth + ",outerHeight=" +
  283.         screen.availHeight + ",screenX=" +
  284.         screen.availLeft + ",screenY=" +
  285.         screen.availTop +
  286.         ",alwaysLowered=1,z-lock=1,dependent=1,titlebar=0,hotkeys=0");
  287.  
  288.     this.webtopHidden = false;
  289.  
  290.     var autoFront = depth.GetNetscapePrefBool("netcaster.webtopFrontmost", false, false);
  291.  
  292.     if (autoFront) {
  293.         this.front();
  294.     }
  295.  
  296.     this.fixButtons();
  297. }
  298.  
  299. function WebtopSetLocation(pageUrl)
  300. {
  301.     var webtop = this.validateWebtop();
  302.     if (!webtop || webtop == null)
  303.     return;
  304.  
  305.     netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite"); 
  306.     webtop.location = pageUrl;
  307. }
  308.  
  309. function WebtopSetItem(dataItem)
  310. {
  311.     var webtop = this.validateWebtop();
  312.     if (!webtop || webtop == null)
  313.     return;
  314.  
  315.     this.webtopItem = dataItem;
  316.     dataItem.setWebtopStatus(true);
  317. }
  318.  
  319. function StartLogoStatusTimer(which, isAnimated) 
  320. {
  321.     var webtop = which.validateWebtop();
  322.  
  323.     if (webtop && !which.webtopWatermark.loading) {
  324.     if (webtop.loading) {
  325.         // only load if it is different
  326.         if (!isAnimated)
  327.         which.webtopWatermark.document.layers[0].document.images[0].src = 'images/logoanim.gif';
  328.         isAnimated = true;
  329.     }
  330.     else {
  331.         if (isAnimated) {
  332.         which.webtopWatermark.document.layers[0].document.images[0].src = 'images/logo.gif';
  333.         which.fixButtons();
  334.         }
  335.             isAnimated = false;
  336.     }
  337.     }
  338.  
  339.     this.logoStatusID = setTimeout(StartLogoStatusTimer, 1500, which, isAnimated);
  340. }
  341.  
  342. function WebtopManager()
  343. {
  344.     this.webtopWindow = null;
  345.     this.webtopHidden = true;
  346.     this.webtopTopped = false;
  347.     this.webtopSite = "";
  348.     this.webtopItem = null;
  349.     
  350.     this.webtopControls = null;
  351.     this.webtopSelectorControls = depth.webcontrols;
  352.     this.webtopWatermark = null;
  353.     this.logoStatusID = 0;
  354.     
  355.     this.validateWebtop = ValidateWebtop;
  356.     
  357.     this.back = WebtopBack;
  358.     this.forward = WebtopForward;
  359.     this.update = WebtopUpdate;
  360.     this.print = WebtopPrint;
  361.     this.closeWebtop = WebtopClose;
  362.     this.toggle = WebtopToggle;
  363.     this.toggleTop = WebtopToggleTop;
  364.     this.hide = WebtopHide;
  365.     this.show = WebtopShow;
  366.     this.front = WebtopFront;
  367.     this.behind = WebtopBehind;
  368.     this.fixButtons = WebtopFixButtons;
  369.     this.openNavigator = OpenNewNavigator;
  370.     
  371.     this.setWebtop = WebtopSet;
  372.     this.setWebtopLocation = WebtopSetLocation;
  373.     this.setWebtopItem = WebtopSetItem;
  374.     this.startLogoStatusTimer = StartLogoStatusTimer;
  375. }
  376.  
  377. void(0);    
  378.